<script setup>
import axios from 'axios';
import { reactive, ref } from 'vue';
let msg = reactive({
  code: '',
  content: ''
})
async function fun1() {
  await axios.get('http://forum.atguigu.cn/api/rand.qinghua?format=json', {
    params: {// 向url后添加的键值对参数
      format: 'json',
      username: 'zhangsan',
      password: '123456'
    }
  }).then(res => {
    Object.assign(msg, res.data);
  }).catch(err => {
    console.error(err);
  });
}
</script>

<template>
  <h1>{{ msg.content }}</h1>
  <button @click="fun1()">切换</button>
</template>

<style scoped></style>
